<template>
  <div>
    <!-- 车辆监控测试  {{menuId}} - {{url}} -->
  
    <iframe
      ref="iframe"
      :src="url"
      @load="embedPlugin"
      style="width: 100%; height: 100%; min-height: calc(100vh - 90px)"
    ></iframe>
  </div>
</template>

<script>
export default {
  name: "carmonitor",
  data() {
    return {
      baseurl: "http://4g.sjzhlkj.cn:9999/gps-web/h5/outside",
      menuId: "101",
      // userId: "admin_gj",
      // password: "ccf6f7b158baa9f7cea1b90a164d5ac3",
      userId: "zhatuxitong",
      password: "f86444cdd94d6562a442f8a6c65b1379",
      controls: "1111",
      url: "",
    };
  },
  created() {
    this.url = this.baseurl + '?menuId=' + this.menuId + '&userId=' + this.userId + '&password=' + this.password + '&controls=' + this.controls
  },
  methods: {
    embedPlugin() {
      // 等待 iframe 加载完成
      const iframe = this.$refs.iframe;
      const doc = iframe.contentDocument || iframe.contentWindow.document;
 
      // 在这里可以操作 iframe 的 DOM
      // 例如，添加第三方网页插件需要的标签或脚本
      doc.open();
      doc.write('<script src="https://third-party-plugin.com/script.js"><\/script>');
      doc.close();
    }

  }
};
</script>
